/**dquery 1.0*/
var noFn=function(){};
var SUPPORTTOUCH = (RegExp("Android").test(navigator.userAgent) || "createTouch" in document);
var touchStart=SUPPORTTOUCH ? "touchstart" : "mousedown";
var touchEnd=SUPPORTTOUCH ? "touchend" : "mouseup";
var touchMove=SUPPORTTOUCH ? "touchmove" : "mousemove";
var touchcancel=SUPPORTTOUCH ? "touchcancel" : "";
var nextFrame = window.requestAnimationFrame
		|| window.webkitRequestAnimationFrame
		|| window.mozRequestAnimationFrame
		|| window.oRequestAnimationFrame
		|| window.msRequestAnimationFrame
		|| function(callback){return setTimeout(callback,10,Date.now());}
var cancelFrame = window.cancelRequestAnimationFrame
		|| window.webkitCancelRequestAnimationFrame
		|| window.mozCancelRequestAnimationFrame
		|| window.oCancelRequestAnimationFrame
		|| window.msCancelRequestAnimationFrame
		|| clearTimeout
var $=(function(){
	var W=window,D=document;
	var Q;
	var queryClass=function(es){
		var self=this;
		this.is$=true;
		this.elements=es;
		this.length=this.elements.length;
		this.eq=function(i){
			return new queryClass(es[i]?[es[i]]:[]);
		}
		this.get=function(i){
			return es[i]||null;
		}
		this.each=function(fn){
			for(var i=0;i<es.length;i++){
				if(fn.call(es[i],i)===false){
					break;
				}
			}
			return this;
		}
		this.add=function(selector){
			if(!selector)	return this;
			var elements=[];
			if(selector.is$===true){
				elements=selector.elements;
			}else if(typeof selector=="string"){
				elements=D.querySelectorAll(selector);
			}else if(typeof selector.length=="number"){
				elements=selector;
			}else if(typeof selector=="object"){
				elements=[selector];
			}
			if(elements.length){
				for(var i=0;i<elements.length;i++){
					this.elements.push(elements[i]);
				}
			}
			return new queryClass(this.elements);
		}
		this.find=function(selector){
			var jes=[];
			this.each(function(){
				var es=this.querySelectorAll(selector);
				if(es.length){
					for(var i=0;i<es.length;i++){
						jes.push(es[i]);
					}
				}
			});
			return new queryClass(jes);
		}
		this.parent=function(){
			var es=[];
			this.each(function(i){
				var p=this.parentNode;
				if(!p.getAttribute("__rn__")){
					es.push(p);
					p.setAttribute("__rn__",1);
				}
			});
			return (new queryClass(es)).each(function(i){
				this.removeAttribute("__rn__");
			});
		}
		this.children=function(selector){
			selector=selector||"*";
			var qc=new queryClass([]);
			this.each(function(i){
				if(this.id){
					qc.add("#"+this.id+">"+selector);
				}else{
					var randomId="__randomId_BGTYHNMJU_"+i;
					this.setAttribute("id",randomId);
					qc.add("#"+randomId+">"+selector);
					this.removeAttribute("id");
				}
			})
			return new queryClass(qc.elements);;
		}
		this.next=function(){
			var els=[];
			this.each(function(i){
				var el=this.nextElementSibling;
				if(el)
					els.push(el);
			})
			return new queryClass(els);;
		}
		this.prev=function(){
			var els=[];
			this.each(function(i){
				var el=this.previousElementSibling;
				if(el)
					els.push(el);
			})
			return new queryClass(els);;
		}
		this.filter=function(fn){
			var newElement=[];
			this.each(function(i){
				if(fn.call(es[i],i)){
					newElement.push(this);
				}
			});
			return new queryClass(newElement);
		}
		this.closest=function(selector){
			var newElement=[];
			var tn,el;
			var candidate=$(selector).attr("__rn__",1);
			this.each(function(i){
				if(candidate.length==0)	return false;
				el=this;
				while(el&&!el.getAttribute("__rn__")&&el.tagName!="HTML"){
					el=el.parentNode;
				}
				if(el&&el.getAttribute("__rn__")==1){
					el.setAttribute("__rn__",2);
					newElement.push(el);
				}
			});
			candidate.each(function(i){
				this.removeAttribute("__rn__");
			})
			return new queryClass(newElement);
		}
		this.siblings=function(selector){
			this.attr("__rn__",1);
			var sibling=[];
			this.each(function(i){
				var sbl=$(this).parent().children(selector).elements;
				for(var i=0;i<sbl.length;i++){
					if(!sbl[i].getAttribute("__rn__")){
						sibling.push(sbl[i]);
						sbl[i].setAttribute("__rn__",1);
					}
				}
			})
			this.each(function(){
				this.removeAttribute("__rn__");
			})
			return (new queryClass(sibling)).each(function(){
				this.removeAttribute("__rn__");
			})
		}
	}
	
	Q=function(selector){
		if(!selector)	return new queryClass([]);
		var elements=[];
		var jes=[];
			if(selector.is$===true){
				return selector;
			}else if(typeof selector=="string"){
				elements=D.querySelectorAll(selector);
			}else if(selector.nodeName){
				elements=[selector];
			}else if(selector.length){
				elements=selector;
			}
		if(elements.length){
			for(var i=0;i<elements.length;i++){
				jes.push(elements[i]);
			}
		}
		return new queryClass(jes);
	}
	Q.q=function(s){return typeof s=="string"?D.querySelector(s):s;}
	Q.qa=function(s){return typeof s=="string"?D.querySelectorAll(s):s;}
	Q.d=function(html){
		var d=D.createElement("div");
		d.innerHTML=html;
		return d.childNodes;
	}
	Q.extend=function(obj){
		if(typeof obj!="object")	return {};
		for(var i=1;i<arguments.length;i++){
			for(var k in arguments[i]){
				obj[k]=arguments[i][k];
			}
		}
		return obj;
	}
	Q.trim=function(str){
		return str.replace(/(^\s+)|(\s+$)/g,"")
	}
	Q.toJSON=function(obj){
		var arr=[];
		if(window.JSON){
			return JSON.stringify(obj);
		}else if(typeof obj=="object"){
			for(var k in obj){
				arr.push('"'+k+'":'+Q.toJSON(obj[k]));
			}
			return "{"+arr.join(",")+"}";
		}else if(typeof obj=="array"){
			for(var i=0;i<obj.length;i++){
				arr.push(Q.toJSON(obj[i]));
			}
			return "["+obj.join(",")+"]";
		}else{
			return '"'+obj.toString()+'"';
		}
	}
	Q.parseJSON=function(json){
		json=Q.trim(json)||"{}";
		var result={};
		try{
			result=JSON.parse(json);
		}catch(e){
			result=(new Function("return "+json))();
		}
		return result;
	}
	Q.toText=function(chars){
		var d=D.createElement("div");
		d.innerHTML=chars;
		return d.innerText;
	}
	Q.toHTML=function(chars){
		var d=D.createElement("div");
		d.innerText=chars;
		return d.innerHTML;
	}
	var creatAjax=function(url,param,okHandle,noHandle,method){
		var xmlHttp = new XMLHttpRequest();
		var paramArr=[];
		method=(method||"get").toUpperCase();
		for(var k in param){
			paramArr.push(k+"="+encodeURIComponent(param[k]));
		}
		if(method=="GET"){
			if(url.indexOf("?")>-1){
				url+="&"+paramArr.join("&");
			}else{
				url+="?"+paramArr.join("&");
			}
		}
		xmlHttp.open(method,url,true);
		xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		xmlHttp.onreadystatechange = function(){
			if(xmlHttp.readyState == 4){
				if(xmlHttp.status == 200){
					okHandle(xmlHttp);
				}else{
					noHandle(xmlHttp);
				}
			}
		};
		xmlHttp.send(method=="GET"?null:paramArr.join("&"));
		return xmlHttp;
	}
	var netError=function(){alert("网络错误")};
	Q.getText=function(url,param,onSuccess,onFail){
		var req=creatAjax(url,param,function(req){
			onSuccess(req.responseText);
		},onFail||netError,"get")
	}
	Q.getJSON=function(url,param,onSuccess,onFail){
		var req=creatAjax(url,param,function(req){
			try{
				var res=Q.parseJSON(req.responseText)
			}catch(e){
				console.info("json error: "+req.responseText);
				return;
			}
			onSuccess(res);
		},onFail||netError,"get")
	}
	Q.postJSON=function(url,param,onSuccess,onFail){
		var req=creatAjax(url,param,function(req){
			try{
				var res=Q.parseJSON(req.responseText)
			}catch(e){
				console.info("json error: "+req.responseText);
				return;
			}
			onSuccess(res);
		},onFail||netError,"post")
	}

	var reaper={};
	Q.promotion=function(name,nirvana){
		reaper[name]=nirvana;
	}
	queryClass.prototype.bankai=function(proc){
		if(this.length==1){
			var tn=this.get(0).tagName;
			if(typeof reaper[tn]=="function")
				reaper[tn](this);
				proc(this);
				if(typeof this.init=="function"){
					this.init();
				}
		}
		return this;
	}
	queryClass.prototype.hide=function(){
		return this.each(function(){
			var s=getComputedStyle(this,null)
			if(s&&s.display!="none"){
				this.__oldDisplay=s.display;
				this.style.display="none";
			}
		})
	}
	queryClass.prototype.show=function(){
		return this.each(function(){
			var s=getComputedStyle(this,null)
			if(s&&s.display=="none"){
				this.style.display=this.__oldDisplay||"block";
			}
		})
	}
	queryClass.prototype.toggle=function(v){	//v是强制值
		return this.each(function(){
			var s=getComputedStyle(this,null);
			if(s.display=="none"&&(v||typeof v=="undefined")){
				this.style.display=this.__oldDisplay||"block";
			}else if(s.display!="none"&&(!v||typeof v=="undefined")){
				this.__oldDisplay=s.display;
				this.style.display="none";
			}
		})
	}
	queryClass.prototype.css=function(css){
		if(typeof css=="string"){
			if(this.elements[0]){
				return getComputedStyle(this.elements[0],null)[css];
			}else{
				return "";
			}
		}else if(typeof css=="object"){
			this.each(function(){
				for(var s in css){
					if(s in this.style){
						this.style[s]=css[s];
					}
				}
			})
		}
		return this;
	}
	queryClass.prototype.offset=function(){
		if(this.elements[0]){
			var el=this.elements[0]
			return {left:el.offsetLeft,top:el.offsetTop,width:el.offsetWidth,height:el.offsetHeight};
		}else{
			return null;
		}
	}
	queryClass.prototype.append=function(html){
		var type=typeof html;
		return this.each(function(){
			if(type=="string"||type=="number"){
				this.insertAdjacentHTML("beforeEnd",html);
			}else if(html.length){
				for(var i=0;i<html.length;i++){
					this.insertAdjacentElement("beforeEnd",html[i]);
				}
			}else if(type=="object"){
				this.insertAdjacentElement("beforeEnd",html);
			}
		})
	}
	queryClass.prototype.prepend=function(html){
		var type=typeof html;
		return this.each(function(){
			if(type=="string"||type=="number"){
				this.insertAdjacentHTML("afterBegin",html);
			}else if(html.length){
				for(var i=0;i<html.length;i++){
					this.insertAdjacentElement("afterBegin",html[i]);
				}
			}else if(type=="object"){
				this.insertAdjacentElement("afterBegin",html);
			}
		})
	}
	queryClass.prototype.remove=function(){
		return this.each(function(){
			this.parentNode.removeChild(this)
		})
	}
	queryClass.prototype.html=function(v){
		if(typeof v!="undefined"){
			return this.each(function(){
				if(typeof this.innerHTML!="undefined")
					this.innerHTML=v;
			})
		}else{
			var vs=[];
			this.each(function(){
				if(typeof this.innerHTML!="undefined")
					vs.push(this.innerHTML);
			})
			return vs.length==1?vs[0]:vs;
		}
	}
	queryClass.prototype.val=function(v){
		if(typeof v!="undefined"){
			return this.each(function(){
				if(typeof this.value!="undefined")
					this.value=v;
			})
		}else{
			var vs=[];
			this.each(function(){
				if(typeof this.value!="undefined")
					vs.push(this.value);
			})
			return vs.length==1?vs[0]:vs;
		}
	}
	queryClass.prototype.attr=function(key,value){
		if(typeof value=="undefined"){
			var v;
			this.each(function(){
				if(v=this.getAttribute(key)){
					return false;
				}
			})
			return v||"";
		}else{
			return this.each(function(){
				this.setAttribute(key,value);
			})
		}
	}
	queryClass.prototype.removeAttr=function(name){
		return this.each(function(){
			this.removeAttribute(name)
		})
	}
	queryClass.prototype.addClass=function(cls){
		var r=new RegExp("(^|\\s)"+cls+"(\\s|$)","g")
		return this.each(function(){
			if(!this.className.match(r)){
				this.className=Q.trim(this.className)+" "+cls;
			}
		})
	}
	queryClass.prototype.removeClass=function(cls){
		var r=new RegExp("(^|\\s)"+cls+"(\\s|$)","g")
		return this.each(function(){
			if(this.className.match(r)){
				this.className=Q.trim(this.className.replace(r," ").replace(/\s+/g," "));
			}
		})
	}
	queryClass.prototype.toggleClass=function(cls){
		var r=new RegExp("(^|\\s)"+cls+"(\\s|$)","g")
		return this.each(function(){
			if(this.className.match(r)){
				this.className=this.className.replace(cls,"").replace(/\s+/g," ").replace(/(^\s+)|(\s+$)/g,"");
			}else{
				this.className+=$.trim(this.className)==""?cls:(" "+cls);
			}
		})
	}
	queryClass.prototype.hasClass=function(cls){
		var has=false;
		var r=new RegExp("(^|\\s)"+cls+"(\\s|$)","g")
		this.each(function(){
			if(this.className.match(r)){
				has=true;
				return false;
			}
		})
		return has;
	}
	queryClass.prototype.blur=function(fn){
		if(typeof fn=="function"){
			this.each(function(){
				this.onblur=fn;
			})
		}else{
			this.each(function(){
				this.onblur();
			})
		}
		return this;
	}
	queryClass.prototype.focus=function(fn){
		if(typeof fn=="function"){
			this.each(function(){
				this.onfocus=fn;
			})
		}else{
			this.each(function(){
				this.onfocus();
			})
		}
		return this;
	}
	queryClass.prototype.change=function(fn){
		if(typeof fn=="function"){
			this.each(function(){
				this.onchange=fn;
			})
		}else{
			this.each(function(){
				this.onchange();
			})
		}
		return this;
	}
	queryClass.prototype.click=function(fn){
		if(typeof fn=="function"){
			this.each(function(){
				this.onclick=fn;
			})
		}else{
			this.each(function(){
				if(typeof this.onclick=="function")
					this.onclick();
			})
		}
		return this;
	}
	queryClass.prototype.one=function(fn){
		if(typeof fn=="function"){
			this.each(function(){
				var func;
				this.addEventListener("click",func=function(){
					fn.apply(this,arguments);
					this.removeEventListener("click",func);
				})
			})
		}
		return this;
	}
	queryClass.prototype.addBind=function(type,fn){		//这个就没办法unbind了
		if(type&&typeof fn=="function"){
			this.each(function(){
				this.addEventListener(type,fn,false)
			})
		}
		return this;
	}
	queryClass.prototype.bind=function(type,fn){
		if(type&&typeof fn=="function"){
			this.each(function(){
				this["on"+type]=fn;
			})
		}
		return this;
	}
	queryClass.prototype.unbind=function(type){
		if(type){
			this.each(function(){
				this["on"+type]=function(){};
			})
			return this;
		}
	}
	queryClass.prototype.delayFn=function(fn,delay){
		this.stop().each(function(){
			clearTimeout(this.timer||0)
			this.timer=setTimeout(fn,delay);
		})
		return this;
	}
	queryClass.prototype.stop=function(){
		this.each(function(){
			clearTimeout(this.timer||0);
		})
		return this;
	}
	queryClass.prototype.nodrop=function(){
		this.each(function(){
			this.removeEventListener(touchStart,this.dropFn,false);
			delete this.dropFn;
		})
	}
	queryClass.prototype.drop=function(startFn,moveFn,endFn,noMoveFn){
		this.each(function(){
			var x0=0,y0=0;
			var startTarget;
			var sx,sy,cx,cy;
			var that=this;
			this.addEventListener(touchStart,this.dropFn=function(event){
				var eTouch=event.touches?event.touches[0]:event;
				var mFn,eFn;
				var moved=0;
				var dp={dx:0,dy:0}
				startTarget=eTouch.target;
				sx=eTouch.screenX;
				sy=eTouch.screenY;
				x0=eTouch.clientX;
				y0=eTouch.clientY;
				//console.info(event._fake)
				if(typeof startFn=="function"){
					startFn.call(that,{
						x:x0,
						x:y0
					});
				}
				D.addEventListener(touchMove,mFn=function(event){
					var eTouch=event.touches?event.touches[0]:event;
					moved=eTouch.clientX-x0||eTouch.clientY-y0;
					if(typeof moveFn=="function"){
						moveFn.call(that,dp={
							dx:eTouch.clientX-x0,
							dy:eTouch.clientY-y0
						});
					}
					if(moved){
						event.preventDefault();
						event.stopPropagation();
					}
				},false);
				D.addEventListener(touchEnd,eFn=function(event){
					D.removeEventListener(touchMove,mFn,false);
					D.removeEventListener(touchEnd,eFn,false);
					if(SUPPORTTOUCH){
						D.removeEventListener(touchcancel,eFn,false);
					}
					//很奇怪,event.touches.length,下面的先干掉
					//{
					//	dx:eTouch.clientX,
					//	dy:eTouch.clientY
					//}
					if(typeof endFn=="function"){
						var eTouch=event;
						endFn.call(that,dp,!!moved);
					}
					if(!moved){
						//console.info("no move")
						if(typeof noMoveFn=="function"){
							noMoveFn.call(that);
						}else{
//							var ev = document.createEvent('MouseEvents');
//							ev.initMouseEvent('click',true,true,window,1,sx,sy,x0,y0,0,0,0,0,0,null);
//							ev._fake = true;
//							startTarget.dispatchEvent(ev);
						}
					}else{
						event.preventDefault();
						event.stopPropagation();
					}
				},false);
				if(SUPPORTTOUCH){
					D.addEventListener(touchcancel,eFn,false);
				}
//				event.preventDefault();
//				event.stopPropagation();
			},false)
		})
		return this;
	}
	return Q;
})();

(function(){
	var color=function(a){
		if(a[0].toString().match(/^#[\da-fA-F]{6}$/)){
			return a[0];
		}
		var r=a[0],
			g=typeof a[1]=="number"?a[1]:r,
			b=typeof a[2]=="number"?a[2]:r,
			a=typeof a[3]=="number"?a[3]:100;
		return "rgba("+r+","+g+","+b+","+(a/100)+")";
	}

	$.promotion("CANVAS",function($c){
		var lastFrameTime=Date.now();
		var timer=0;
		var canvas=$c.get(0);
		var c2d=$c.c2d=canvas.getContext("2d");
		$c.loop=true;
		$c.frameRate=20;
		$c.frameCount=0;
		$c.width=canvas.width;		//background用的
		$c.height=canvas.height;
		$c.draw=noFn;
		$c.stage=noFn;
		$c.init=function(){
			this.stage(c2d);
			if(this.loop)
				timer=nextFrame(frameFunc);
		};
		$c.mouseDown=noFn;
		$c.addBind(touchStart,function(e){
			if($c.mouseDown==noFn)	return;
			var eTouch=e.touches?e.touches[0]:event;
			var offset=$c.offset();
			$c.mouseDown(c2d,eTouch.pageX-offset.left,eTouch.pageY-offset.top,e);
		})
		$c.mouseMove=noFn;
		$c.addBind(touchMove,function(e){
			if($c.mouseMove==noFn)	return;
			var eTouch=e.touches?e.touches[0]:event;
			var offset=$c.offset();
			$c.mouseMove(c2d,eTouch.pageX-offset.left,eTouch.pageY-offset.top,e);
		})
		$c.mouseUp=noFn;
		
		$c.size=function(w,h){
			h=h||w;
			this.width=w;
			this.height=h;
			canvas.setAttribute("width",w);
			canvas.setAttribute("height",h);
			return this;
		}
		$c.background=function(){
			c2d.clearRect(0,0,this.width,this.height);
			if(arguments[3]){
				c2d.fillStyle = color(arguments);  
				c2d.fillRect(0,0,this.width,this.height);
			}
			return this;
		};
		$c.strokeWeight=function(weight){
			c2d.lineWidth = weight;  
			return this;
		}
		$c.stroke=function(){
			if(arguments.length==1&&isNaN(arguments[0]))
				c2d.strokeStyle = arguments[0];
			else if(arguments.length)
				c2d.strokeStyle = color(arguments);
			else
				c2d.stroke()
			return this;
		}
		$c.fill=function(){
			if(arguments.length==1&&isNaN(arguments[0]))
				c2d.fillStyle = arguments[0];
			else if(arguments.length)
				c2d.fillStyle = color(arguments);  
			else
				c2d.fill();
			return this;
		}
		$c.line=function(/*arguments*/){
			c2d.beginPath();
			c2d.moveTo(arguments[0],arguments[1]);
			for(var i=2,l=arguments.length;i<l;i+=2){
				c2d.lineTo(arguments[i],arguments[i+1]);
			}
			c2d.stroke();
			return this;
		}
		$c.rect=function(x,y,w,h,noStroke){
			c2d.beginPath();
			c2d.rect(x,y,w,h);
			if(!noStroke)
				c2d.stroke();
			return this;
		}
		$c.ellipse=function(x,y,R,r){
			r=r||R;
			var i=0,x1,y1;
			c2d.beginPath();
			c2d.moveTo(R+x,y);
			//c2d.arc(x,y,r,0,2*Math.PI,false);
			while(i<181){
				x1=R*Math.cos(i*Math.PI/90)+x;
				y1=r*Math.sin(i*Math.PI/90)+y;
				c2d.lineTo(x1,y1);
				i++;
			}
			c2d.stroke();
			return this;
		}
		$c.drawImg=function(pic,x,y,width,height){
			pic.width=Math.min(pic.width,pic.img.width-pic.x);
			pic.height=Math.min(pic.height,pic.img.height-pic.y);
			width=width||pic.width;
			height=height||pic.height;
			if(Math.min(pic.width,pic.height)<=0||Math.min(width,height)<=0){
				//console.log(arguments,pic.width,pic.height);
				return false;
			}
			c2d.drawImage(pic.img,pic.x,pic.y,pic.width,pic.height,x,y,width,height);
		},
		$c.path={
			begin:function(x,y){
				c2d.beginPath();
				c2d.moveTo(x,y);
				return this;
			},
			moveTo:function(x,y){
				c2d.moveTo(x,y);
				return this;
			},
			lineTo:function(/*arguments*/){
				for(var i=0,l=arguments.length;i<l;i+=2){
					c2d.lineTo(arguments[i],arguments[i+1]);
				}
				this.x0=arguments[i-2];
				this.y0=arguments[i-1];
				return this;
			},
			arcTo:function(bx,by,x,y,r){	//arcTo是直线圆角拐弯用的:(bx,by)是尖角拐弯点,弧半径为r,跟path终点与(x,y)的连线也相切
				c2d.arcTo(bx,by,x,y,r);
				c2d.lineTo(x,y);
				return this;
			},
			bezierTo:function(cpx,cpy,x,y){
				c2d.quadraticCurveTo(cpx,cpy,x,y);
				return this;
			},
			close:function(){
				c2d.closePath();
				return this;
			},
			stroke:function(){
				c2d.stroke();
				return this;
			},
			fill:function(){
				c2d.fill();
				return this;
			},
			clip:function(){
				c2d.clip();
				return this;
			}
		}
		$c.stop=function(){
			$c.loop=false;
			//console.log(timer)
			cancelFrame(timer);
			return this;
		}
		$c.play=function(){
			this.stop();
			$c.loop=true;
			timer=nextFrame(frameFunc);
			return this;
		};
		var frameFunc=function(frameTime){
			frameTime=frameTime||Date.now();
			if(frameTime-lastFrameTime>=1000/$c.frameRate){
			//	console.log(frameTime-lastFrameTime,1000/that.frameRate);
				lastFrameTime=frameTime;
				$c.draw(c2d);
				$c.frameCount++;
				//console.log(canvas.width)
			}
			if($c.loop)
				timer=nextFrame(frameFunc);
		}
	})
})();
(function(){
		  
	$.promotion("AUDIO",function($a){
		var el=$a.get(0);
		el.autoplay=false;
		var eventTester = function(e){
			el.addEventListener(e,function(){
				console.log((new Date()).toTimeString()+" "+e);
			});
		}
//		eventTester("loadstart");   //客户端开始请求数据
//		//eventTester("progress");    //客户端正在请求数据
//		eventTester("suspend");     //延迟下载
//		eventTester("abort");       //客户端主动终止下载（不是因为错误引起），
//		eventTester("error");       //请求数据时遇到错误
//		eventTester("stalled");     //网速失速
//		eventTester("play");        //play()和autoplay开始播放时触发
//		eventTester("pause");       //pause()触发
//		eventTester("loadedmetadata");  //成功获取资源长度
//		eventTester("loadeddata");  //
//		eventTester("waiting");     //等待数据，并非错误
//		eventTester("playing");     //开始回放
//		eventTester("canplay");     //可以播放，但中途可能因为加载而暂停
//		eventTester("canplaythrough"); //可以播放，歌曲全部加载完毕
//		eventTester("seeking");     //寻找中
//		eventTester("seeked");      //寻找完毕
//		//eventTester("timeupdate");  //播放时间改变
//		eventTester("ended");       //播放结束
//		eventTester("ratechange");  //播放速率改变
//		eventTester("durationchange");  //资源长度改变
//		eventTester("volumechange");    //音量改变
		
		$a.index=0;
		$a.mount=function(){};
		$a.init=function(){
			$a.list=[];
			$a.index=0;
			$a.mount(el);
			//el.loop=true;
		//	for(var eventName in events){
		//		el.addEventListener(eventName,events[eventName]);
		//	}
		}
		$a.p=function(){
			el.autoplay=true;
			if(el.paused){
				el.play();
			}else{
				el.pause();
			}
			return el.paused;
		}
		$a.play=function(i){
			if(isNaN(i)){
				this.p();
			}else{
				this.index=i;
				$a.loadSrc();
				el.play();
			}
		}
		$a.currEntry=function(){
			return this.list[this.index];
		}
		$a.playLast=function(){
			this.index--;
			if(!this.currEntry()){
				this.index=this.list.length-1;
			}
			$a.loadSrc();
		}
		$a.playNext=function(){
			this.index++;
			if(!this.currEntry()){
				this.index=0;
			}
			$a.loadSrc();
		}
		$a.loadSrc=function(){
			el.src=this.currEntry().url;
			el.loop=!!this.currEntry().loop;
			el.load();
		}
	})
})()